function encodedBits = WiSiL_Encoder_trellisTermination(bits,state,constraint)

%
%     This function perfoms the trellis termination for the turbo coding
%     according to 36.212.
%     
%
% Syntax:   
%   encodedBits = trellisTermination(bits,poly,state)
%   Input parameters:
%     bits : The encoded bits.
%     state:  the shift registers state of the recursive convolutional
%     codes.
%
%   Output parameters:
%     encodedBits : The bits related to a frame after the trellis
%     termination is performed.

%
% History:
% Rafhael Medeiros de Amorim ( rma.petit@gmail.com )
% July 30th, 2008.

poly = [03 15];
tail = [0 0 0];

trellis = poly2trellis(constraint,poly);

auxiliar(1,:) = convenc(tail,trellis,state(1));
auxiliar(2,:) = convenc(tail,trellis,state(2));

tailbits = [auxiliar(1,:) auxiliar(2,:)];
tailbits=reshape(tailbits,3,[]);

encodedBits = [bits, tailbits];
